<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
    $(document).ready(function(){
        $("#language").change(function() {
            //console.log($("#language").val());
            //alert($(location).attr('href'));
            /*
            $.ajax({  
              type: "POST",
              url: "<?php echo site_url(); ?>" + "/router/filter_pages/" + $("#language").val(),
              success: function() {  
                  
              }
            });
            return false;
            */
           $(location).attr('href',"<?php echo site_url(); ?>" + "/router/view_pages/" + $("#language").val());
        });
    });  
</script>
<h2>View pages</h2>
<form method="POST">
    <table cellpadding="0" cellspacing="0" width="100%"> 
        <tr>
            <td>Language</td>
            <td>
                <select id="language" name="language">
                    <?php
                        if(!empty($language)) {
                    ?>                    
                            <option value=<?php echo $language['language_id'] ?>><?php echo $language['name'] ?></option>
                    <?php
                        }
                    ?>                    
                    <?php
                        if(!empty($languages)) {
                            foreach ($languages as $key => $language) {
                    ?>
                                <option value=<?php echo $language['language_id'] ?>><?php echo $language['name'] ?></option>
                    <?php
                            }
                        }
                    ?>
                </select>
            </td>
        </tr>
    </table>
</form>
<table cellpadding="0" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <?php
            if (!empty($pages)) {
                foreach ($pages as $key => $page) {
        ?>
                    <tr>
                        <td><?php echo $page['name'] ?></td>
                        <td><a href="<?php echo site_url() . "/router/edit_page/" . $page['content_id'] ?>">edit</a> | <a href=<?php echo site_url() . "/content/content_controller/delete/" . $page['content_id'] ?>>delete</a></td>
                    </tr>
        <?php
                }
            }
        ?>
    </tbody>
</table>